Dxl script works fine inside doors appplication but through command line giving an error

I have a Dxl script which works fine when i run it via Doors>Edit>Dxl option but when i run the same script via command line getting an error message.

Please find the my scrip which is getting an error along with Batch script which has been used to call the Dxl

  1. pragma runLim,0
  2. string s = "/DS-B2/Change Proposal System/Suggestions" //module location
  3. Item i = item s
  4. if (exists module s)
  5. {
  6. Module w = read("/DS-B2/Change Proposal System/Suggestions") //module location
  7. current w
  8. bool confirm (string z) { print "Confirmed: " z "\n"; return true }
  9. void ack (string z) {print "Acknowledge: " z "\n" }
  10. void infobox (string z) {print "Info: " z "\n" }
  11. void info (string z) {print "Info: " z "\n" }
  12. DB theDiag = null
  13. void show (DB x) { realize x; theDiag = x }
  14. void block (DB x) { realize x; theDiag = x }
  15. if (null current Module) {
  16. print "You need to have a current Module set for the export."
  17. }
  18. {#include
  19. standard/export/office/word.dxl
  20. set(exportHeadingsToggle, false)

  21. set(exportLayoutChoice, 1)

  22. doExport theDiag
  23. if (!null theDiag) destroy theDiag
  24. }
  25. }

Batch Script

cd C:\Program Files\IBM\Rational\DOORS\9.6\bin doors.exe -d 36690@cob1022940.cob.apac -dxl "C:\export\export.dxl" -u Administrator -P Admin@12 -project "/DS-B2"


Vijaykumar_natarajan - Wed May 10 07:41:16 EDT 2017

Re: Dxl script works fine inside doors appplication but through command line giving an error
Mathias Mamsch - Thu May 11 12:52:08 EDT 2017

Try "current = w" instead of "current w"

Re: Dxl script works fine inside doors appplication but through command line giving an error
Vijaykumar_natarajan - Fri May 12 01:05:25 EDT 2017

Mathias Mamsch - Thu May 11 12:52:08 EDT 2017

Try "current = w" instead of "current w"

Thank you for the answer.

Unfortunately, the same problem still exist even after changing to "current = w"

Re: Dxl script works fine inside doors appplication but through command line giving an error
thsturm - Fri May 12 03:13:07 EDT 2017

Mathias Mamsch - Thu May 11 12:52:08 EDT 2017

Try "current = w" instead of "current w"

I have the observation, that read() changes the current Module:

pragma encoding, "UTF-8"

Module origCurrMod = current Module
print "'" fullName(current Module) "' 1\n"

Module mod = read("/Sturm/ModuleB")
print "'" fullName(current Module) "' 2\n"
Object obj
for obj in current Module do {
        print identifier obj "\n"
}
//close mod
print "'" fullName(current Module) "' 3\n"
print "'" fullName(origCurrMod) "' 4\n"

current = origCurrMod
print "'" fullName(current Module) "' 5\n"

 

with the output:

'/Sturm/ModuleA' 1
'/Sturm/ModuleB' 2
B-1
B-5
B-2
B-3
B-4
B-6
'/Sturm/ModuleB' 3
'/Sturm/ModuleA' 4
'/Sturm/ModuleA' 5

 

I had the problem to save the original module handle and to open several modules for read()/edit() and than work again in the original module.

Re: Dxl script works fine inside doors appplication but through command line giving an error
Mathias Mamsch - Fri May 12 04:00:57 EDT 2017

thsturm - Fri May 12 03:13:07 EDT 2017

I have the observation, that read() changes the current Module:

pragma encoding, "UTF-8"

Module origCurrMod = current Module
print "'" fullName(current Module) "' 1\n"

Module mod = read("/Sturm/ModuleB")
print "'" fullName(current Module) "' 2\n"
Object obj
for obj in current Module do {
        print identifier obj "\n"
}
//close mod
print "'" fullName(current Module) "' 3\n"
print "'" fullName(origCurrMod) "' 4\n"

current = origCurrMod
print "'" fullName(current Module) "' 5\n"

 

with the output:

'/Sturm/ModuleA' 1
'/Sturm/ModuleB' 2
B-1
B-5
B-2
B-3
B-4
B-6
'/Sturm/ModuleB' 3
'/Sturm/ModuleA' 4
'/Sturm/ModuleA' 5

 

I had the problem to save the original module handle and to open several modules for read()/edit() and than work again in the original module.

There is a "golden rule" for DXL regarding current: 

1. Inside your script, you use "current" only once! Right at the start of the script to read and store the current module. You do this before any includes, before any other code (that might change the current module). Afterwards you NEVER use current, only the stored module handle. 

2. Whenever you use a builtin function that explicitly relies on the current module, you simply set the current module before calling the function, e.g. 

current = myModule

if (exists attribute "blahblah" ) { /* relies on current */ }

3. If you care about other code, then you can store the current module and set it back after your function, e.g.

Module oldCurrent = current;

current = myModule

if (exists attribute "blahblah" ) { /* relies on current */ }

current = oldCurrent; 

 

but 3. is too much pain for me. Whoever relies on current invites their own bad luck!

Maybe that helps, regards, Mathias

Re: Dxl script works fine inside doors appplication but through command line giving an error
thsturm - Fri May 12 04:06:57 EDT 2017

Mathias Mamsch - Fri May 12 04:00:57 EDT 2017

There is a "golden rule" for DXL regarding current: 

1. Inside your script, you use "current" only once! Right at the start of the script to read and store the current module. You do this before any includes, before any other code (that might change the current module). Afterwards you NEVER use current, only the stored module handle. 

2. Whenever you use a builtin function that explicitly relies on the current module, you simply set the current module before calling the function, e.g. 

current = myModule

if (exists attribute "blahblah" ) { /* relies on current */ }

3. If you care about other code, then you can store the current module and set it back after your function, e.g.

Module oldCurrent = current;

current = myModule

if (exists attribute "blahblah" ) { /* relies on current */ }

current = oldCurrent; 

 

but 3. is too much pain for me. Whoever relies on current invites their own bad luck!

Maybe that helps, regards, Mathias

Thank you.

These are indeed "golden rules", and it is a habit of mine to save the current Module.

New for me was, that read()/edit() changes the current Module.